﻿<Window x:Class="ApiScannerShell.Views.TestRunnerView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Core="clr-namespace:ApiScanner.Core;assembly=ApiScanner.Core" xmlns:System="clr-namespace:System;assembly=mscorlib" Title="TestRunnerView" MinHeight="400" MinWidth="600" Height="400" Width="600" x:Name="Root">
	<Grid DataContext="{Binding ViewModel, ElementName=Root}" Grid.IsSharedSizeScope="True">

		<Grid.Resources>
			<DataTemplate DataType="{x:Type Core:FileSystemArtifact}">
				<Grid>
					<Grid.ColumnDefinitions>
                        <ColumnDefinition SharedSizeGroup="Description"  Width="Auto" />
                        <ColumnDefinition SharedSizeGroup="Value" Width="*" />
                    </Grid.ColumnDefinitions>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto" />
						<RowDefinition Height="Auto" />
						<RowDefinition Height="Auto" />
						<RowDefinition Height="Auto" />
					</Grid.RowDefinitions>
					<TextBlock Grid.Row="0" Grid.ColumnSpan="2" Style="{StaticResource Artifactheader}" Text="DLL Dependency" />
					<TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource Text}" Text="Filename:" />
					<TextBlock Grid.Row="1" Grid.Column="1" Style="{StaticResource TextValue}" Text="{Binding FileName}" />
					<TextBlock Grid.Row="2" Grid.ColumnSpan="2" Style="{StaticResource Text}" Text="Found references:" />
					<ItemsControl Grid.Row="3" Grid.ColumnSpan="2" ItemsSource="{Binding DllsFound}">
						<ItemsControl.ItemTemplate>
							<DataTemplate DataType="{x:Type System:String}">
								<TextBlock Style="{StaticResource ListBoxValue}" Text="{Binding}" />
							</DataTemplate>
						</ItemsControl.ItemTemplate>
						<ItemsControl.ItemsPanel>
							<ItemsPanelTemplate>
								<WrapPanel Orientation="Vertical" Style="{StaticResource IndentedPanel}" />
							</ItemsPanelTemplate>
						</ItemsControl.ItemsPanel>
					</ItemsControl>
				</Grid>
			</DataTemplate>
            <DataTemplate DataType="{x:Type Core:SmtpServerEventBinding}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition SharedSizeGroup="Description"  Width="Auto" />
                        <ColumnDefinition SharedSizeGroup="Value" Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Row="0" Grid.ColumnSpan="2" Style="{StaticResource Artifactheader}" Text="SMTP Eventsink" />
                    <TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource Text}" Text="Displayname:" />
                    <TextBlock Grid.Row="1" Grid.Column="1" Style="{StaticResource TextValue}" Text="{Binding Name}" />
                    <TextBlock Grid.Row="2" Grid.Column="0" Style="{StaticResource Text}" Text="Sink class:" />
                    <TextBlock Grid.Row="2" Grid.Column="1" Style="{StaticResource TextValue}" Text="{Binding SinkClass}" />
                </Grid>
            </DataTemplate>
            <DataTemplate DataType="{x:Type Core:StoreEventBinding}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition SharedSizeGroup="Description"  Width="Auto" />
                        <ColumnDefinition SharedSizeGroup="Value" Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Row="0" Grid.ColumnSpan="2" Style="{StaticResource Artifactheader}" Text="Exchange store event sink" />
                    <TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource Text}" Text="Displayname:" />
                    <TextBlock Grid.Row="1" Grid.Column="1" Style="{StaticResource TextValue}" Text="{Binding Name}" />
                    <TextBlock Grid.Row="2" Grid.Column="0" Style="{StaticResource Text}" Text="Url:" />
                    <TextBlock Grid.Row="2" Grid.Column="1" Style="{StaticResource TextValue}" Text="{Binding Url}" />
                    <TextBlock Grid.Row="3" Grid.Column="0" Style="{StaticResource Text}" Text="Sink class:" />
                    <TextBlock Grid.Row="3" Grid.Column="1" Style="{StaticResource TextValue}" Text="{Binding SinkClass}" />
                    <TextBlock Grid.Row="4" Grid.Column="0" Style="{StaticResource Text}" Text="Match scope:" />
                    <TextBlock Grid.Row="4" Grid.Column="1" Style="{StaticResource TextValue}" Text="{Binding MatchScope}" />
                    <TextBlock Grid.Row="5" Grid.Column="0" Style="{StaticResource Text}" Text="Criteria:" />
                    <TextBlock Grid.Row="5" Grid.Column="1" Style="{StaticResource TextValue}" Text="{Binding Criteria}" />
                    <TextBlock Grid.Row="6" Grid.Column="0" Style="{StaticResource Text}" Text="Script url:" />
                    <TextBlock Grid.Row="6" Grid.Column="1" Style="{StaticResource TextValue}" Text="{Binding ScriptUrl}" />
                </Grid>
            </DataTemplate>
            <DataTemplate DataType="{x:Type Core:ScannerError}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition SharedSizeGroup="Description"  Width="Auto" />
                        <ColumnDefinition SharedSizeGroup="Value" Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Row="0" Grid.ColumnSpan="2" Style="{StaticResource Artifactheader}" Text="Error" />
                    <TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource Text}" Text="Location:" />
                    <TextBlock Grid.Row="1" Grid.Column="1" Style="{StaticResource TextValue}" Text="{Binding Location}" />
                    <TextBlock Grid.Row="2" Grid.Column="0" Style="{StaticResource Text}" Text="Message:" />
                    <TextBlock Grid.Row="2" Grid.Column="1" Style="{StaticResource TextValue}" Text="{Binding Exception.Message}" />
                </Grid>
            </DataTemplate>
        </Grid.Resources>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="*" />
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>
		<WrapPanel Orientation="Vertical" Grid.Row="0" Style="{StaticResource HeaderPanel}">
			<TextBlock Style="{StaticResource Heading}" Text="Scanning for Exchange events" />
			<TextBlock Style="{StaticResource SubHeading}" Text="The test you configured are being executed. Depending on the configuration, this can take several hours to complete." />
		</WrapPanel>
		<DockPanel Grid.Row="1">
			<Grid DockPanel.Dock="Top">
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
				</Grid.ColumnDefinitions>
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
				</Grid.RowDefinitions>
				<TextBlock Grid.Row="0" Grid.Column="0" Style="{StaticResource Text}" Text="Starttime:" />
				<TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource Text}" Text="Time elapsed:" />
				<TextBlock Grid.Row="0" Grid.Column="1" Style="{StaticResource TextValue}" Text="{Binding StartTime}" />
				<TextBlock Grid.Row="1" Grid.Column="1" Style="{StaticResource TextValue}" Text="{Binding ElapsedTime}" />
			</Grid>
			<TextBlock DockPanel.Dock="Top" Style="{StaticResource Text}" Text="Current action:" />
			<TextBlock DockPanel.Dock="Top" Style="{StaticResource TextValue}" Text="{Binding CurrentAction.Message}" />
            <TabControl Style="{StaticResource TabControl}">
				<TabItem>
                    <TabItem.Header>
                        <TextBlock>
                            <Run Text="Detected events (" />
                            <TextBlock Text="{Binding Events.Count}" />
                            <Run Text=")" />
                        </TextBlock>
                    </TabItem.Header>
					<Grid>
						<DockPanel Grid.Column="0">
							<TextBlock DockPanel.Dock="Top" Style="{StaticResource Text}" Text="Events:" />
							<ListBox ItemsSource="{Binding Events}" Style="{StaticResource ListBox}" />
						</DockPanel>
					
					</Grid>
				</TabItem>
				<TabItem>
                    <TabItem.Header>
                        <TextBlock>
                            <Run Text="Errors (" />
                            <TextBlock Text="{Binding Errors.Count}" />
                            <Run Text=")" />
                        </TextBlock>
                    </TabItem.Header>
					<Grid>
						<DockPanel Grid.Column="0">
							<TextBlock DockPanel.Dock="Top" Style="{StaticResource Text}" Text="Events:" />
							<ListBox ItemsSource="{Binding Errors}" Style="{StaticResource ListBox}" />
						</DockPanel>
					
					</Grid>
				</TabItem>
				<TabItem>
                    <TabItem.Header>
                        <TextBlock>
                            <Run Text="Message log (" />
                            <TextBlock Text="{Binding Messages.Count}" />
                            <Run Text=")" />
                        </TextBlock>
                    </TabItem.Header>
					<ListView ItemsSource="{Binding Messages}">
						<ListView.View>
							<GridView>
								<GridViewColumn Header="Date" DisplayMemberBinding="{Binding Date}" />
								<GridViewColumn Header="Message" DisplayMemberBinding="{Binding Message}" />
							</GridView>
						</ListView.View>
						<ListView.ItemsPanel>
							<ItemsPanelTemplate>
								<VirtualizingStackPanel />
							</ItemsPanelTemplate>
						</ListView.ItemsPanel>
					</ListView>
				</TabItem>
			</TabControl>
		</DockPanel>
		<Grid Grid.Row="2" Style="{StaticResource FooterPanel}">
			<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
				<Button Style="{StaticResource Button}" Command="{Binding CloseCommand}" Content="Close" CommandParameter="{Binding ElementName=Root}" />
			</StackPanel>
		</Grid>
	</Grid>
</Window>